/**
 * The Prophecy
 * java based lightweight texas hold'em poker software base
 * http://code.google.com/p/theprophecy/
 */

package org.poker.prophecy.simulation.demo;

import java.util.Vector;

import org.poker.prophecy.player.general.Player;
import org.poker.prophecy.player.primitiv.CheckerPlayer;
import org.poker.prophecy.player.primitiv.FiftyFiftyRaiserPlayer;
import org.poker.prophecy.player.primitiv.FirstDornPlayer;
import org.poker.prophecy.simulation.Dealer;
import org.poker.prophecy.simulation.Table;

/**
 * @author bg
 */

public class DornSimulationDemo {

	public static void main (String args[]){
	 	Table table = new Table("SimulationsDemosTable");
	 
	 	table.addPlayer(new FirstDornPlayer("Berni", 3000, table)); 
	 	table.addPlayer(new FirstDornPlayer("Tusek", 3000, table));
	 	table.addPlayer(new FirstDornPlayer("Flavio", 3000, table));
	 	table.addPlayer(new FirstDornPlayer("Alex", 3000, table));
	 	table.addPlayer(new FirstDornPlayer("Meschi", 3000, table));
	 	table.addPlayer(new FirstDornPlayer("Frank", 3000, table));
	 	table.addPlayer(new FirstDornPlayer("Nico", 3000, table));
	 	table.addPlayer(new FirstDornPlayer("Tiischer", 3000, table));
	 	
	 	table.tickTableInfo();
	 	
	 	Dealer dealer = new Dealer(table);
	 	
	 	dealer.initGame();
	 	
	 	long starTime = System.currentTimeMillis() / 1000;
	 	long currTime = starTime;

	 	while(lastManStanding(table)>1 && (currTime - starTime) < 180 ){
	 		dealer.deal();
	 		table.passDealerButton();
	 		
	 		currTime = System.currentTimeMillis() / 1000;
	 	}
	 		
	 	table.getTableTicker().tick("");
	 	table.getTableTicker().tick("GAME OVER");
	 	table.getTableTicker().tick("Endstats:");
	 	table.tickTableInfo();
	}
	
	
	public static int lastManStanding(Table table){
		int stillStanding = 0;
		
		Vector<Player> players = new Vector<Player>();
		players = table.getPlayers();
		for (int i = 0; i < players.size(); i++) {
			if (players.elementAt(i).getMoney() > 0) stillStanding++; 
		}
		
		return stillStanding;
	}
	
	
	
}
